package cn.shengchao.rule.condition.valueType;

import cn.hutool.core.date.DateUtil;
import cn.shengchao.rule.condition.matchType.IMatchType;

import java.util.Date;
import java.util.List;

/**
 * @program: examstarapi
 * @description: 日期天数类型
 * @author: Xiong weiqiang
 * @create: 2025-04-11 14:39
 */
public class DateValueType implements IValueType{
    @Override
    public List<String> getAvailableMatchTypes() {
        return List.of(IMatchType.EQUALS,
                IMatchType.GREATER_THAN,
                IMatchType.GREATER_AND_EQUALS,
                IMatchType.LESS_THAN,
                IMatchType.LESS_AND_EQUALS,
                IMatchType.DATE_RANGE_IN
        );
    }

    @Override
    public String valueTypeKey() {
        return IValueType.TYPE_DATE;
    }

    @Override
    public String valueTypeName() {
        return "时间";
    }

    public static String parseDateToValue(String date){
        return Long.valueOf(DateUtil.parse(date,"yyyy-MM-dd HH:mm:ss").getTime()).toString();
    }

    public static String parseValueToDate(String longValue){
        return DateUtil.format(new Date(Long.parseLong(longValue)),"yyyy-MM-dd HH:mm:ss");
    }
}